/**
 * Created by   :Wangshuzhong
 * Created time :2019/08/08
 */
require(["vue","ELEMENT"], function (Vue, Element) {
  Vue.use(Element)
  var Config = $("body").data("config"); // 配置文件内容
  window.app = new Vue({
    el: '#app',
    data: {
      activeName: 'index', // 显示的导航
      activeSecName: '', // 显示的二级导航
      bannerList: ['img/index/banner_00172.png', 'img/index/banner_00172.png'], // 轮播图列表
      showNum: 0, // 第几张显示
      msg: 'hello!东方驿站',
      userName: 'wsz',
      password: '123456',
      newsNum: 0,
      autoPlay: true,
      indexData: {}, // 首页所有数据
      newsList: [] // 动态数据
    },
    created: function() {
      var self = this;
      //获取首页信息
      Config.Request('post', Config.apiUrl.getIndexInfo).then(function(res) {
        if(res.code == 200) {
          self.indexData = res.data;
          self.newsList = res.data.information;
        } else {
          self.$message.error(res.message)
        }
      }).catch(function(error) {
        self.$message.error(error)
      })
    },
    mounted:function() {

    },
    methods: {
      // 轮播改变
      changeBan:function(newPage, oldPage) {
        this.newsNum = newPage
        if(newPage == 0) {
          this.$refs.newsInfoBanner.setActiveItem(newPage)
        } else {
          this.$refs.newsInfoBanner.setActiveItem(newPage*2)
        }
      },
      //指定轮播页
      toPage:function(index) {
        this.$refs.newsBanner.setActiveItem(index)
        this.newsNum = index
      },
      //转换序号
      turnPageText:function(index) {
        return index > 8 ? index + 1 : '0' + (index + 1)
      },
      mouseEvent:function() {
        this.autoPlay = !this.autoPlay
      },
      // 新闻详情
      viewNewInfo:function(id) {
        window.location.href = 'newsInfo.html' + '?code=' + id;
      }
    }
  });
})
